package org.eclipse.milo.examples.client;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class test {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        Future<String> stringFuture = calculateAsync();
        System.out.println(" then do another things");
        System.out.println(stringFuture.get());
    }

    public static Future<String> calculateAsync(){
        CompletableFuture<String> completableFuture = new CompletableFuture<>();
        /*Executors.newCachedThreadPool().submit(() -> {
            Thread.sleep(10000);

            completableFuture.complete("Hello");

            String s = completableFuture.get();
            System.err.println("我好了 现在传给你"+s);
            return null;

        });*/
        new Thread(()->{
            completableFuture.complete("12333");
        }).start();
        return completableFuture;
    }
}
